package com.coocaa.ops.admin.v1.tab.biz.impl;

import com.coocaa.ops.admin.v1.tab.biz.ITabPanelRlsBiz;
import com.coocaa.ops.admin.v1.tab.mapper.ITabPanelRlsMapper;
import com.coocaa.ops.common.core.base.BaseBizImpl;
import com.coocaa.ops.common.core.base.mybatis.QueryTemplate;
import com.coocaa.ops.common.core.biz.tab.entity.TabPanelRlsEntity;
import org.springframework.stereotype.Service;

/**
 * @author bjh
 * @description 版面和板块关联表-biz层接口实现
 * @date 2020-06-17 21:36:46
 */
@Service
public class  TabPanelRlsBizImpl extends BaseBizImpl<ITabPanelRlsMapper, TabPanelRlsEntity> implements ITabPanelRlsBiz {
    @Override
    public void updateTabPanelRlsFlag(Integer id, Integer version, Integer flag) {
        QueryTemplate<TabPanelRlsEntity> queryTemplate = QueryTemplate.getEqQueryTemplate("flag", 1);
        queryTemplate.lambda().eq(TabPanelRlsEntity::getTabId, id)
                .eq(TabPanelRlsEntity::getTabVersion, version);
        TabPanelRlsEntity update = new TabPanelRlsEntity();
        update.setFlag(flag);
        getMapper().update(update, queryTemplate);
    }

    @Override
    public void deleteRls(Integer id, Integer version) {
        QueryTemplate<TabPanelRlsEntity> queryTemplate =QueryTemplate.getEqQueryTemplate("flag", 1);
        queryTemplate.lambda().eq(TabPanelRlsEntity::getTabId, id)
                .eq(TabPanelRlsEntity::getTabVersion, version);
        if (getMapper().selectCount(queryTemplate) > 0){
            getMapper().delete(queryTemplate);
        }
    }
}
